package com.ruoyi.wasterTran.service.impl;

import java.util.Date;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.RandomUtils;
import com.ruoyi.common.utils.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wasterTran.mapper.TConstructionWasteTransportationOrderMapper;
import com.ruoyi.wasterTran.domain.TConstructionWasteTransportationOrder;
import com.ruoyi.wasterTran.service.ITConstructionWasteTransportationOrderService;

/**
 * 建筑垃圾联运订单信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@Service
public class TConstructionWasteTransportationOrderServiceImpl implements ITConstructionWasteTransportationOrderService 
{
    @Autowired
    private TConstructionWasteTransportationOrderMapper tConstructionWasteTransportationOrderMapper;

    /**
     * 查询建筑垃圾联运订单信息
     * 
     * @param id 建筑垃圾联运订单信息主键
     * @return 建筑垃圾联运订单信息
     */
    @Override
    public TConstructionWasteTransportationOrder selectTConstructionWasteTransportationOrderById(String id)
    {
        return tConstructionWasteTransportationOrderMapper.selectTConstructionWasteTransportationOrderById(id);
    }

    /**
     * 查询建筑垃圾联运订单信息列表
     * 
     * @param tConstructionWasteTransportationOrder 建筑垃圾联运订单信息
     * @return 建筑垃圾联运订单信息
     */
    @Override
    public List<TConstructionWasteTransportationOrder> selectTConstructionWasteTransportationOrderList(TConstructionWasteTransportationOrder tConstructionWasteTransportationOrder)
    {
        return tConstructionWasteTransportationOrderMapper.selectTConstructionWasteTransportationOrderList(tConstructionWasteTransportationOrder);
    }

    /**
     * 新增建筑垃圾联运订单信息
     * 
     * @param tConstructionWasteTransportationOrder 建筑垃圾联运订单信息
     * @return 结果
     */
    @Override
    public int insertTConstructionWasteTransportationOrder(TConstructionWasteTransportationOrder tConstructionWasteTransportationOrder)
    {
        // 电子联单号
        String tranOrderCode = RandomUtils.genCode(new Date());
        tConstructionWasteTransportationOrder.setTranOrderCode(tranOrderCode);
        SnowflakeIdUtils idWorker = new SnowflakeIdUtils(1, 3);
        tConstructionWasteTransportationOrder.setId(idWorker.nextId()+"");
        tConstructionWasteTransportationOrder.setCreateTime(DateUtils.getNowDate());
        //创建工单的时候就是开始装运的时间
        tConstructionWasteTransportationOrder.setStartTime(DateUtils.getTime());
        return tConstructionWasteTransportationOrderMapper.insertTConstructionWasteTransportationOrder(tConstructionWasteTransportationOrder);
    }

    /**
     * 修改建筑垃圾联运订单信息
     * 
     * @param tConstructionWasteTransportationOrder 建筑垃圾联运订单信息
     * @return 结果
     */
    @Override
    public int updateTConstructionWasteTransportationOrder(TConstructionWasteTransportationOrder tConstructionWasteTransportationOrder)
    {
        tConstructionWasteTransportationOrder.setUpdateTime(DateUtils.getNowDate());
        return tConstructionWasteTransportationOrderMapper.updateTConstructionWasteTransportationOrder(tConstructionWasteTransportationOrder);
    }

    /**
     * 批量删除建筑垃圾联运订单信息
     * 
     * @param ids 需要删除的建筑垃圾联运订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTConstructionWasteTransportationOrderByIds(String[] ids)
    {
        return tConstructionWasteTransportationOrderMapper.deleteTConstructionWasteTransportationOrderByIds(ids);
    }

    /**
     * 删除建筑垃圾联运订单信息信息
     * 
     * @param id 建筑垃圾联运订单信息主键
     * @return 结果
     */
    @Override
    public int deleteTConstructionWasteTransportationOrderById(String id)
    {
        return tConstructionWasteTransportationOrderMapper.deleteTConstructionWasteTransportationOrderById(id);
    }
}
